This function simply looks to see if the brace closes a "do-while"
clause and if so, returns the list `(before)' indicating that a newline
should be inserted before the brace, but not after it. In all other
cases, it returns the list `(before after)' so that the brace appears
on a line by itself.
During the call to the brace hanging ACTION function, the variable
`c-syntactic-context' is bound to the full syntactic analysis list.
Note that for symmetry, colon hanginess should be customizable by
allowing function symbols as ACTIONs on the `c-hanging-colon-alist'
variable. Since no use has actually been found for this feature, it
isn't currently implemented!
File: cc-mode.info, Node: Customizing Semi-colons and Commas, Next: Other Special Indentations, Prev: Custom Brace and Colon Hanging, Up: Advanced Customizations
Customizing Semi-colons and Commas
----------------------------------
You can also customize the insertion of newlines after semi-colons
and commas, when the auto-newline minor mode is enabled (see *Note
Minor Modes::). This is controlled by the variable
`c-hanging-semi&comma-criteria', which contains a list of functions
that are called in the order they appear. Each function is called with
zero arguments, and is expected to return one of the following values:
* non-`nil' -- A newline is inserted, and no more functions from the
list are called.
* `stop' -- No more functions from the list are called, but no
newline is inserted.
* `nil' -- No determination is made, and the next function in the
list is called.
If every function in the list is called without a determination being
made, then no newline is added. The default value for this variable is a
list containing a single function which inserts newlines only after
semi-colons which do not appear inside parenthesis lists (i.e. those
that separate `for'-clause statements).
Here's an example of a criteria function that will prevent newlines
from being inserted after semicolons when there is a non-blank following
line. Otherwise, it makes no determination. To use, add this to the
front of the `c-hanging-semi&comma-criteria' list.
(defun my-semicolon-criteria ()
(save-excursion
(if (and (eq last-command-char ?\;)
(zerop (forward-line 1))
(not (looking-at "^[ \t]*$")))
'stop
nil)))
File: cc-mode.info, Node: Other Special Indentations, Prev: Customizing Semi-colons and Commas, Up: Advanced Customizations
Other Special Indentations
--------------------------
In `gnu' style (see *Note Built-in Styles::), a minimum indentation
is imposed on lines inside top-level constructs. This minimum
indentation is controlled by the variable
`c-label-minimum-indentation'. The default value for this variable is
1.
One other customization variable is available in CC Mode:
`c-special-indent-hook'. This is a standard hook variable that is
called after every line is indented by CC Mode. You can use it to do
any special indentation or line adjustments your style dictates, such
as adding extra indentation to constructors or destructor declarations
in a class definition, etc. Note however, that you should not change
point or mark inside your `c-special-indent-hook' functions (i.e.
you'll probably want to wrap your function in a `save-excursion').
Setting `c-special-indent-hook' in your style definition is handled
slightly differently than other variables. In your style definition,
you should set the value for `c-special-indent-hook' to a function or
list of functions, which will be appended to `c-special-indent-hook'
using `add-hook'. That way, the current setting for the buffer local
value of `c-special-indent-hook' won't be overridden.
Normally, the standard Emacs command `M-;' (`indent-for-comment')
will indent comment only lines to `comment-column'. Some users
however, prefer that `M-;' act just like `TAB' for purposes of
indenting comment-only lines; i.e. they want the comments to always
indent as they would for normal code, regardless of whether `TAB' or
`M-;' were used. This behavior is controlled by the variable
`c-indent-comments-syntactically-p'. When `nil' (the default), `M-;'
indents comment-only lines to `comment-column', otherwise, they are
indented just as they would be if `TAB' were typed.